package com.lancoo.ccas52.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lancoo.ccas52.config.MybatisRedisCache;
import com.lancoo.ccas52.entity.TeachingClass;
import com.lancoo.ccas52.entity.TeachingClassWeek;
import com.lancoo.ccas52.pojo.common.GroupObject;
import com.lancoo.ccas52.pojo.dto.ArrangeTeachingClassDto;
import com.lancoo.ccas52.pojo.dto.ExcelTeachingClass;
import com.lancoo.ccas52.pojo.dto.SyncTeachingClassDto;
import com.lancoo.ccas52.pojo.vo.*;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)
public interface TeachingClassMapper extends BaseMapper<TeachingClass> {

    int addBatch(@Param("teachingClassCollection") Collection<TeachingClass> teachingClassCollection);

    List<Long> getClassIdsByTaskId(@Param("taskIds") List<Integer> taskIds);

    /**
     * 条件获取课程教学班
     *
     * @param page
     * @param taskId
     * @param handleState
     * @param selectState
     * @param courseTypeId
     * @param courseNature
     * @param collegeId
     * @param keyWord
     * @return
     */
    IPage<TeachingClassCourseDto> getTeachingClassByConditions(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("handleState") Integer handleState, @Param("selectState") Integer selectState, @Param("courseTypeId") String courseTypeId,
                                                               @Param("studyNature") Integer studyNature, @Param("courseNature") Integer courseNature,@Param("majorProp") Integer majorProp, @Param("collegeId") String collegeId, @Param("keyWord") String keyWord, @Param("teachingClassType") Integer teachingClassType, @Param("minClassNum") Integer minClassNum);


    /**
     * 确定选课列表 获取在线选课教学班
     * @param page
     * @param taskId
     * @param handleState
     * @param selectState
     * @param courseTypeId
     * @param studyNature
     * @param courseNature
     * @param majorProp
     * @param collegeId
     * @param keyWord
     * @param minClassNum
     * @return
     */
    IPage<TeachingClassCourseDto> getSelectionTeachingClass(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("handleState") Integer handleState, @Param("selectState") Integer selectState, @Param("courseTypeId") String courseTypeId,
                                                               @Param("studyNature") Integer studyNature, @Param("courseNature") Integer courseNature,@Param("majorProp") Integer majorProp, @Param("collegeId") String collegeId, @Param("keyWord") String keyWord, @Param("minClassNum") Integer minClassNum);

    /**
     * 获取简单教学班
     *
     * @param page
     * @param taskId
     * @param collegeId
     * @param keyWord
     * @return
     */
    IPage<RuleTeachingClassVo> getSimpleTeachingClass(@Param("page") IPage page, @Param("taskId") Integer taskId,@Param("courseTypeId") String courseTypeId, @Param("courseNature") Integer courseNature,@Param("majorProp") Integer majorProp,
                                                      @Param("collegeId") String collegeId, @Param("keyWord") String keyWord, @Param("state") Integer state);

    /**
     * 根据行政班获取拆班教学班
     * @param taskId
     * @param toClass
     * @return
     */
    List<TeachingClassSubVoNew> getSubTeachingClass( @Param("taskId") Integer taskId, @Param("toClass") String toClass);


    /**
     * 获取课程教学班 主要用于课表，关联数据较少提升速度
     *
     * @param page
     * @param taskId
     * @param courseTypeId
     * @param studyNature
     * @param courseNature
     * @param collegeId
     * @return
     */
    IPage<TeachingClassCourseDto> getTeachingClass(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("courseTypeId") String courseTypeId, @Param("studyNature") Integer studyNature, @Param("courseNature") Integer courseNature,@Param("majorProp") Integer majorProp,
                                                   @Param("collegeId") String collegeId, @Param("teachingClassIds") List<Long> teachingClassIds,@Param("keyWord") String keyWord);

    /**
     * 根据行政班获取教学班
     * @param taskId
     * @param classIds
     * @return
     */
    List<TeachingClassToClassDto> getTeachingClassByClassId( @Param("taskId") Integer taskId, @Param("classIds") List<String> classIds);
    IPage<TeachingClassSegmentDto> getSegmentTeachingClass(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("courseTypeId") String courseTypeId, @Param("studyNature") Integer studyNature,
                                                   @Param("collegeId") String collegeId, @Param("teachingClassIds") List<Long> teachingClassIds,@Param("keyWord") String keyWord);
    /**
     * 获取环节教学班
     *
     * @param page
     * @param taskId
     * @param segmentTypeId
     * @param studyNature
     * @param collegeId
     * @param keyWord
     * @return
     */
    IPage<TeachingClassSegmentDto> getTeachingClassSegment(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("segmentTypeId") String segmentTypeId,
                                                           @Param("studyNature") Integer studyNature, @Param("collegeId") String collegeId, @Param("keyWord") String keyWord);

    /**
     * 根据课程id获取教学班
     * @param flag
     * @param courseId
     * @param studyNature
     * @param teachingClassType
     * @return
     */
    List<TeachingClass> getTeachingClassByCourseId(@Param("flag") Integer flag,@Param("courseId") Long courseId, @Param("studyNature") Integer studyNature, @Param("teachingClassType") Integer teachingClassType);

    /**
     * 根据分班唯一标识获取教学班
     * @param uniqueShiftSign
     * @return
     */
    List<TeachingClass> getTeachingClassByShiftsign(@Param("uniqueShiftSign") String uniqueShiftSign);

    /**
     * g根据教学班类型
     *
     * @param taskId
     * @param teachingClassType
     * @return
     */
    List<TeachingClassCourseDto> getSelectStatistic(@Param("taskId") Integer taskId, @Param("teachingClassType") int teachingClassType);

    /**
     * 获取选课去重人数
     * @param taskId
     * @param teachingClassType
     * @return
     */
    Integer getSelectStudent(@Param("taskId") Integer taskId, @Param("teachingClassType") int teachingClassType);


    /**
     * 退选统计-在线选课
     *
     * @param taskId
     * @return
     */
    List<TeachingClassCourseDto> getDeselectStatistic(@Param("taskId") Integer taskId);

    /**
     * 获取课程教学班 排课数据
     *
     * @param taskId
     * @param campusId
     * @return
     */
    List<ArrangeTeachingClassDto> getCourseArrangeTeachingClassDto(@Param("taskId") Integer taskId, @Param("campusId") String campusId,
                                                                   @Param("collegeId") String collegeId,@Param("majorProp") Integer majorProp,@Param("teachingClassId") Long teachingClassId);

    List<ArrangeTeachingClassDto> getSegmentArrangeTeachingClassDto(@Param("taskId") Integer taskId, @Param("campusId") String campusId);

    /**
     * 获取教学班 排课数据
     * @param page
     * @param taskId
     * @param state
     * @param isLocked
     * @param collegeId
     * @param studyNature
     * @return
     */
    IPage<TeachingClassCourseDto> getCourseTeachingClassForArrange(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("state") Integer state,
                                                                   @Param("isLocked") Integer isLocked, @Param("collegeId") String collegeId, @Param("studyNature") Integer studyNature,@Param("majorProp") Integer majorProp);

    /**
     * g根据教学班id获取课程教学班
     * @param teachingClassId
     * @return
     */
    TeachingClassCourseDto getCourseTeachingClassById(@Param("teachingClassId") Long teachingClassId);

    /**
     * 获取教学班 排课数据统计
     * @param taskId
     * @param collegeId
     * @param majorProp
     * @return
     */
    List<ArrangeStatistics> getArrangeStatistics(@Param("taskId") Integer taskId,  @Param("collegeId") String collegeId,@Param("majorProp") Integer majorProp);


    /**
     * 获取环节教学班 排课数据
     * @param page
     * @param taskId
     * @param state
     * @param collegeId
     * @param studyNature
     * @return
     */
    IPage<TeachingClassSegmentDto> getSegmentTeachingClassForArrange(@Param("page") IPage page, @Param("taskId") Integer taskId, @Param("state") Integer state,  @Param("collegeId") String collegeId, @Param("studyNature") Integer studyNature);


    List<SyncTeachingClassDto> syncCourseTeachingClassDto(@Param("taskId") Integer taskId, @Param("teachingClassType") Integer teachingClassType);

    List<SyncTeachingClassDto> syncSegmentTeachingClassDto(@Param("taskId") Integer taskId);

    /**
     * 根据教学班id获取教学班 课程信息
     * @param teachingClassId
     * @return
     */
    StudentCourseVo getTeachingClassCourse(@Param("teachingClassId") Long teachingClassId);

    /**
     * 根据课程名获取 全部教学班名
     * @param taskId
     * @param courseNames
     * @return
     */
    List<GroupObject<String,String>> getTeachingClassNameByCourseName(@Param("taskId") Integer taskId, @Param("courseNames") List<String> courseNames);

    /**
     * 获取待导出教学任务教学班信息
     * @param taskId
     * @return
     */
    List<ExcelTeachingClass> getExcelTeachingClass (@Param("taskId") Integer taskId);

    /**
     * 获取存在教室的教学班参数
     * @param courseId
     * @param studyNature
     * @return
     */
    List<TeachingClassWeek> getExistRoomTeachingClassWeek (@Param("courseId") Long courseId, @Param("studyNature") Integer studyNature,@Param("hourType") Integer hourType);

    /**
     * 获取不存在教室的单双号拆班教学班
     * @param taskId
     * @return
     */
    List<TeachingClass> getNotExistRoomTeachingClass (@Param("taskId") Integer taskId);
}